home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr53
/
pctv4n_1.zip
/
WRAPTEST.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-06-10
|
2KB
|
59 lines
program WrapTest;
uses DBWrap;
var
RC : integer; {holds return codes from engine}
EBEngine : TEBEngine;
db : PEBDatabase;
view : PEBView;
Entry_Date : PEBField; {we'll use this field a lot}
F : text;
EDate, XNum, Desc : string;
Add, Update : boolean;
ed, date : longint;
begin
EBEngine.Init;
db := EBEngine.OpenDatabase('XDATA');
View := db^.View('trans', {table}
'entry_date,x_number,description', {fields}
'main'); {index}
Entry_Date := View^.Field('entry_date');
assign(F, 'XACTIONS.TXT'); {file of transactions shown in mag}
reset(F);
repeat
readln(F, EDate); {Conversion errors will be caught}
readln(F, XNum); {by the object, whereas non-OOP }
readln(F, Desc); {app assumed everything was OK.}
Entry_Date^.Store(EDate); {Magic: store as a string into}
ed := Entry_Date^.AsInteger; {date field & retrieve as long}
Add := false; Update := false;
rc := View^.Search(XNum);
If RC = -1 then Add := true {record doesn't exist, so add it}
else If RC = 0 then {record exists; should we update?}
begin
Date := Entry_date^.AsInteger;
If date <= ed then Update := true;
end;
If Add or Update then {Store everything at once}
begin
View^.Store(EDate+ParseChar+XNum+ParseChar+Desc);
If Add then View^.Add
else View^.Update;
end;
until(eof(F)); {No more transactions to process}
Dispose(View, Done);
Dispose(db, Done);
writeln('Process Completed. No errors.');
end.